package com.kefu.call.vo;

import javax.validation.constraints.NotEmpty;

import org.apache.commons.lang3.StringUtils;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.kefu.common.context.KefuContext;
import com.kefu.common.vo.AbstractSearchVo;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

/**
 * @author francis
 * @date 2021/05/22
 */
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@ApiModel(description = "活动用户")
public class ActivityUserInfoSearchVo extends AbstractSearchVo {

	@NotEmpty
    @ApiModelProperty(value = "活动Id")
    private String activityId;
    @ApiModelProperty(value = "创建时间")
    private Long createTime;
    @ApiModelProperty(value = "创建人")
    private String createUser;
    @ApiModelProperty(value = "修改时间")
    private Long updateTime;
    @ApiModelProperty(value = "修改人")
    private String updateUser;
    @ApiModelProperty(value = "数据状态0 无效，1有效",hidden=true)
    private Integer dataStatus=1;
    @ApiModelProperty(value = "租户")
    private String tenantId;
    @ApiModelProperty(value = "用户ID")
    private String userId;
    @ApiModelProperty(value = "用户姓名")
    private String userName;

    public <T>QueryWrapper<T> builder() {
  		QueryWrapper<T> wrapper=Wrappers.query();
	    if (StringUtils.isNotBlank(activityId)) {
	        wrapper.eq("activity_id", activityId);
	    }
		if (createTime != null) {
		    wrapper.eq("create_time", createTime);
		}
	    if (StringUtils.isNotBlank(createUser)) {
	        wrapper.eq("create_user", createUser);
	    }
		if (updateTime != null) {
		    wrapper.eq("update_time", updateTime);
		}
	    if (StringUtils.isNotBlank(updateUser)) {
	        wrapper.eq("update_user", updateUser);
	    }
		if (dataStatus != null) {
		    wrapper.eq("data_status", dataStatus);
		}
	    if (StringUtils.isNotBlank(tenantId)) {
	        wrapper.eq("tenant_id", tenantId);
	    }
	    if (StringUtils.isNotBlank(userId)) {
	        wrapper.eq("user_id", userId);
	    }
	    if (StringUtils.isNotBlank(userName)) {
	        wrapper.eq("user_name", userName);
	    }
	    wrapper.eq("tenant_id", KefuContext.getKefuContext().getTenantId());
	    return wrapper;
	}
}